package cn.kgc.boot.tcuser.controller;

import cn.kgc.boot.util.ImportDataFromExl;
import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@Controller
public class FileController {


    @RequestMapping(value = "toImportFile")
    public String toImportFile(){
        return "importFile";
    }


    /**
     * 这是test
     *  导入exl文件数据
     * @param file exl文件
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "importFileData")
    public String importFileData(MultipartFile file){
        try {
            // 测试
            List<List<String>> excelData = ImportDataFromExl.getExcelData(file);
//            HashMap<String, HashSet<String>> classData = ImportDataFromExl.getClassData(excelData);
//            return JSON.toJSONString(excelData) + JSON.toJSONString(classData);
            return JSON.toJSONString(excelData);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }






}
